#pragma once

#include <sys_reg.h>

#define USBFS_Q 0x50000000

typedef enum {
	USBFS_GOTGCS_R = 0x0,
	USBFS_GOTGINTF_R = 0x4,
	USBFS_GAHBCS_R = 0x8,
	USBFS_GUSBCS_R = 0xC,
	USBFS_GRSTCTL_R = 0x10,
	USBFS_GINTF_R = 0x14,
	USBFS_GINTEN_R = 0x18,
	USBFS_GRSTATR_R = 0x1C,
	USBFS_GRSTATP_R = 0x20,
	USBFS_GRFLEN_R = 0x24,
	USBFS_HNPTFLEN_DIEP0TFLEN_R = 0x28,
	USBFS_HNPTFQSTAT_R = 0x2C,
	USBFS_GCCFG_R = 0x38,
	USBFS_CID_R = 0x3C,
	USBFS_HPTFLEN_R = 0x100,
	USBFS_HCTL_R = 0x400,
	USBFS_HFT_R = 0x404,
	USBFS_HFINFR_R = 0x408,
	USBFS_HPTFQSTAT_R = 0x410,
	USBFS_HACHINT_R = 0x414,
	USBFS_HACHINTEN_R = 0x418,
	USBFS_HPCS_R = 0x440,
	USBFS_DCFG_R = 0x800,
	USBFS_DCTL_R = 0x804,
	USBFS_DSTAT_R = 0x808,
	USBFS_DIEPINTEN_R = 0x810,
	USBFS_DOEPINTEN_R = 0x814,
	USBFS_DAEPINT_R = 0x818,
	USBFS_DAEPINTEN_R = 0x81C,
	USBFS_DVBUSDT_R = 0x828,
	USBFS_DVBUSPT_R = 0x82C,
	USBFS_DIEPFEINTEN_R = 0x834,
	USBFS_DIEP0CTL_R = 0x900,
	USBFS_DIEP0LEN_R = 0x910,
	USBFS_DOEP0CTL_R = 0xB00,
	USBFS_DOEP0LEN_R = 0xB10,
	USBFS_PWRCLKCTL_R = 0xE00,
} usbfs_re;

static inline u32_s usbfs_get_reg_q(usbfs_re usbfs_r) {
	return USBFS_Q + usbfs_r;
}

static inline void usbfs_wreg(usbfs_re usbfs_r, u32_s value) {
	u32_s reg_q = usbfs_get_reg_q(usbfs_r);
	wreg(reg_q, value);
}

static inline u32_s usbfs_rreg(usbfs_re usbfs_r) {
	u32_s reg_q = usbfs_get_reg_q(usbfs_r);
	return rreg(reg_q);
}
